const express = require('express');
const axios = require('axios');
const router = express.Router();

// 第三方天气接口（厦门城市ID，可替换为目标城市ID）
const WEATHER_API = 'http://t.weather.sojson.com/api/weather/city/101230501';

// 后端接口：处理天气请求
router.get('/', async (req, res) => {
  try {
    const response = await axios.get(WEATHER_API);
    res.json(response.data);
  } catch (error) {
    console.error('天气接口请求失败：', error);
    res.status(500).json({ status: 500, message: '天气数据获取失败' });
  }
});

module.exports = router;